home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5444 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.oanet.com!usenet
  2. From: sunrise@oanet.com (sunrise)
  3. Newsgroups: comp.lang.c++
  4. Subject: ??:Re:'Scanf("%p%*c",&p) and Memory
  5. Date: 4 Feb 1996 21:39:09 GMT
  6. Organization: OA Internet
  7. Message-ID: <4f391t$2rg@hermes.oanet.com>
  8. NNTP-Posting-Host: dialin60.oanet.com
  9. X-Newsreader: WinVN 0.92.6+
  10.  
  11.  
  12.  
  13.  Hi.  I'm working on a problem which takes an address (large memory model)
  14. from a user and displays its memory contents in Hex.  I've found an 
  15. example which uses the folowing but I don't understand the scanf.
  16.              
  17.               register int i;
  18.               unsigned char far *p;
  19.               unsigned ch;
  20.               
  21.          scanf("%p%*c",&p);
  22.         
  23.          for (i=1;i<=256;i++){
  24.           ch=*p;
  25.           printf("%02x ",ch);
  26.           p++;  }
  27.  
  28. The program does essentially what I want, but I need to know...
  29. What does the "%p%*c" within the scanf do???  How does it work???
  30. Also how can I increment the p pointer so that the segment increaces
  31. and not just the offset (as the above example does).
  32.  
  33. -Sunrise
  34.